--[[
@author Aurelien Deharbe

This file is part of Cute-Client.

Cute-Client is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Cute-Client is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Cute-Client.  If not, see <http://www.gnu.org/licenses/>.
]]

package.path = package.path .. ";../cuteclient/?.lua"
qsclient = require("csclient")
require("cssession")
socket = require("socket")

c = csclient.CSClient.init("localhost", 5000)
s = c:newSession("example05")

data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

window = s:qs("QMainWindow()")
button = s:qs("QPushButton('send data', "..window..") -> sendbtn")
s:qs(window..".show()")

while true do
	for i = 1,10 do
		data[i] = math.random(9)
	end
	t = data
	print(t[1]..t[2]..t[3]..t[4]..t[5]..t[6]..t[7]..t[8]..t[9]..t[10])
	s:putData("<data>", data)
	socket.select(nil, nil, 3)
end

s:mainloop()
